<?php
if (isset($InputData['list_type'])) {
    //如果为作品待审核列表 加入审核按钮
    if ($InputData['list_type'] == work_m::ListTopicWait && $_SESSION['user_level'] >= 90) {
        $works_list_btn_show = 1;
    } //如果为作品选择加入本领列表
    elseif ($InputData['list_type'] == work_m::ListUserForField) {
        if (isset($_SESSION['user_field_work_list'])) {
            $user_field_work_list = array();
            $_user_field_work_list = explode(',', $_SESSION['user_field_work_list']);
            foreach ($_user_field_work_list as $value) {
                $user_field_work_list[$value] = 1;
            }
        }
        $works_list_btn_show = 2;
    } //如果为作品在本领中排序
    elseif ($InputData['list_type'] == work_m::ListUserField) {
        $works_list_btn_show = 3;
    } elseif ($InputData['list_type'] == work_m::ListUserForTopic) {
        $works_list_btn_show = 4;
        $i = 0;
        echo '<span id="msg_topic_id" style="display:none">' . $InputData['topic_id'] . '</span>';
    } else {
        $works_list_btn_show = 0;
    }
} else {
    $works_list_btn_show = 0;
}
if (isset($workList) && count($workList) > 0) {
    foreach ($workList as $workMsg) {
        $workImg = make_img_name::make_img_micro_name(explode(';', $workMsg->Picture, 2)[0]);
        if (count($workImg) > 0) {
            $isRecommend = $myWork->work_recommend_check($workMsg->Id);
            if ($isRecommend === true) $recommendIconEx = ''; else $recommendIconEx = '-o';
            $isCommend = $myWork->work_comment_check($workMsg->Id);
            if ($isCommend === true) $commendIconEx = ''; else $commendIconEx = '-o';
            ?>
            <li class="am-g" data-id="<?= $workMsg->Id ?>" style="padding: 10px 5px" <?php
            if ($works_list_btn_show < 2) echo "onclick=\"goto_work_show($workMsg->Id)\"";
            ?>>
                <div class="am-u-sm-3 am-list-thumb">
                    <div class="app-img-flex"
                         style="background-image:url(<?= $CfgPara->httproot ?>/works_pic/<?= $workImg; ?>);">
                    </div>
                </div>
                <div class=" am-u-sm-7 am-u-end am-list-main">
                    <div class="am-list-item-hd">
                        <span class="app-main-color"><?= $workMsg->Name; ?></span>
                    </div>
                    <div class="am-list-item-text">
                        <?php if ($workMsg->State == 1) { ?>
                        <i class="am-icon am-icon-heart<?= $recommendIconEx ?> am-icon-fw"></i><?= formatDataSize($workMsg->UpCount) ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <i class="am-icon am-icon-comment<?= $commendIconEx ?> am-icon-fw"></i><?= formatDataSize($workMsg->CommentCount) ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <i class="am-icon am-icon-eye am-icon-fw"></i><?= formatDataSize($workMsg->ViewCount) ?>
                        <?php } else { ?>
                            <i class="am-icon am-icon-edit am-icon-fw"></i>草稿
                        <?php } ?>
                    </div>
                </div>
                <?php
                //作品待审核列表 加入审核按钮
                if ($works_list_btn_show === 1) {
                    echo '<button class="am-fr app-btn-showlist app-btn-follow" onclick="topic_work_check(' . $InputData['topic_id'] . ',' . $workMsg->Id . ',this,1)">&nbsp;通过&nbsp;</button>';
                    echo '<button style="margin-top: 10px" class="am-fr app-btn-showlist app-btn-follow-red" onclick="topic_work_check(' . $InputData['topic_id'] . ',' . $workMsg->Id . ',this,-1)">&nbsp;拒绝&nbsp;</button>';
                } //作品选择加入本领列表
                elseif ($works_list_btn_show === 2) {
                    if (!isset($user_field_work_list[$workMsg->Id]))
                        echo '<button class="am-fr app-btn-showlist app-btn-follow" onclick="user_field_add_work(' . $workMsg->Id . ',this)" datatype="1">加入</button>';
                    else
                        echo '<button class="am-fr app-btn-showlist app-btn-followed" onclick="user_field_add_work(' . $workMsg->Id . ',this)" datatype="0">取消</button>';
                } //作品本领列表排序
                elseif ($works_list_btn_show === 3) {
                    echo
                    '<span class="am-fr btn-field-order" style="display:none">
                <button class="am-icon-arrow-circle-o-up am-icon-fw app-main-color" onclick="user_field_order_up(this)"></button>
                <button class="am-icon-arrow-circle-o-down am-icon-fw app-main-color" onclick="user_field_order_down(this)"></button>
            </span>';
                } //选择作品投稿到专题
                elseif ($works_list_btn_show === 4) {
                    if ($topicAddCheckResult[$i] == -2 || $topicAddCheckResult[$i] == -1)
                        echo '<button class="am-fr app-btn-showlist app-btn-follow" onclick="work_for_topic(this)" data-topic-msg="' . $InputData['topic_id'] . ',' . $workMsg->Id . '">&nbsp;投&nbsp;稿&nbsp;</button>';
                    elseif ($topicAddCheckResult[$i] == 0)
                        echo '<button class="am-fr app-btn-showlist app-btn-followed">待审核</button>';
                    else
                        echo '<button class="am-fr app-btn-showlist app-btn-followed">已加入</button>';
                    $i++;
                }
                ?>
            </li>
        <?php } //if(count($workImg) > 0)结束
    }//foreach ($workList as $workMsg) 结束
} //if(isset($workList))结束
else //没有内容
{
    if (!isset($InputData['page_change']) || isset($InputData['search_text']))
        require("{$CfgPara->root}/view/warning_nocontent.app.v.php");
}
?>